/**
 * Project hdmap
 * @author shengjialiang
 * @version v1.0
 */


#ifndef _OBJECTMAP_H
#define _OBJECTMAP_H

#include "OpenThreads/Mutex"
#include "map_common/Object.h"

namespace Common
{
	class MAP_COMMON_EXPORTS CObjectMap
        : public Common::CObject
    {
    public:
        CObjectMap();

        virtual ~CObjectMap();

		virtual bool add(const std::string& in_key, Common::CObject* in_pRefObject);

        int size();

        std::vector<std::string> getKeys();

        Common::CObject* get(const std::string& in_key);

        bool exist(const std::string& in_key);

        Common::CObject* remove(const std::string& in_key);

        bool removeAndDestroy(const std::string& in_key);

        bool removeAll();

        bool removeAllAndDestroy();

        bool get(std::vector<Common::CObject*>& inout_objects);

    private:
        void lock();

        void unlock();

    private:
        std::map<std::string,Common::CObject*> mObjects;
        OpenThreads::Mutex mMutex;
    };
}
#endif //_OBJECTMAP_H